/**
 * Lab2Driver.java
 *
 * Enterprise Java
 *
 * Author:  Matthew Braddy
 * Created: Nov 22, 2010
 *
 */

package java113.labs;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
import java113.dataAccess.DataManager;

/**
 *
 * @author Matthew Braddy
 */
public class Lab2Driver {

    public static void main(String[] args) throws Exception {

        Properties properties = new Properties();

        try {

            properties.load(new FileInputStream("./config/lab.properties"));

        } catch(IOException ioe) {

            System.out.println("Can't load the properties file");

            ioe.printStackTrace();

        } catch(Exception e) {

            System.out.println("Problem: " + e);

            e.printStackTrace();

        }

        properties.setProperty("webApp", "false");

        DataManager m_oDataManager = new DataManager(properties);

        NameDAO nameDAO = new NameDAO(properties, m_oDataManager);
        ArrayList names = nameDAO.getAllNames();

        for (Iterator it = names.iterator(); it.hasNext();) {
            
            Name name = (Name) it.next();
            AddressDAO addressDAO = new AddressDAO(properties, m_oDataManager);
            Address address = addressDAO.getAddress(name.getAddress_id());

            ClassificationDAO classificationDAO = new ClassificationDAO(properties, m_oDataManager);
            Classification classification = classificationDAO.getClassification(name.getClassification_id());

            System.out.println(name.toString());

            System.out.println(classification.toString());

            System.out.println(address.toString());
        }
    }

}
